//
//  PhotoBigImageViewController.m
//  1gene
//
//  Created by 1jiyin on 16/3/15.
//  Copyright © 2016年 1jiyin. All rights reserved.
//
//***************将相册选取的图片放大***************
#import "PhotoBigImageViewController.h"

@interface PhotoBigImageViewController ()
///*
// *存放图片的scrollView
// */
//@property(nonatomic,copy)UIScrollView *myScrollView;
///*
// *pageControl的位置
// */
//@property(nonatomic,copy)UIPageControl *pageControl;
///*
// *scrollView中当前图片的位置
// */
//@property(nonatomic,assign)NSInteger currentImagePage;
@end

@implementation PhotoBigImageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:[UIView new]];
    self.view.backgroundColor=[UIColor whiteColor];
//    _currentImagePage=_imageTag-1;
    [self createUI];
    [self createNavigation];
    // Do any additional setup after loading the view.
}
-(void)createNavigation
{
    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    //返回
    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 0, 25, 25);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    
    UIButton *rightBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    rightBtn.frame=CGRectMake(0, 0, 40, 30);
    rightBtn.titleLabel.font=[UIFont systemFontOfSize:15];
    [rightBtn setTitle:@"删除" forState:UIControlStateNormal];
    [rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(rightBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:rightBtn];
}

//返回上一页
-(void)leftBtnClick:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark 删除
-(void)rightBtnClick:(UIButton *)sender
{
    self.deleteImage(_imageTag);
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)createUI
{
    UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 20+44, self.view.frame.size.width, self.view.frame.size.height-20-44)];
       imgView.image=_img;
       [self.view addSubview:imgView];
}
//-(void)createUI
//{
//    _myScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 20+44, self.view.frame.size.width, self.view.frame.size.height-20-44)];
//    _myScrollView.delegate=self;
//    _myScrollView.pagingEnabled=YES;
//    _myScrollView.contentSize=CGSizeMake(self.view.frame.size.width*[_imageArray count], _myScrollView.frame.size.height);
//    _myScrollView.showsHorizontalScrollIndicator=NO;
//    _myScrollView.bounces=NO;
//    for (int i=0; i<_imageArray.count; i++) {
//        UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*i, 0, self.view.frame.size.width, _myScrollView.frame.size.height)];
//        imgView.image=((UIImageView *)_imageArray[i]).image;
//        imgView.tag=i+1;
//        [_myScrollView addSubview:imgView];
//    }
//    [self.view addSubview:_myScrollView];
//    _myScrollView.contentOffset=CGPointMake(self.view.frame.size.width*(_imageTag-1), 0);
//    
//    
//    _pageControl=[[UIPageControl alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height*0.8, self.view.frame.size.width, 30)];
//    _pageControl.pageIndicatorTintColor=[UIColor yellowColor];
//    _pageControl.numberOfPages=_imageArray.count;
//    //_pageControl.backgroundColor=[UIColor redColor];
//    _pageControl.currentPageIndicatorTintColor=[UIColor greenColor];
//    _pageControl.currentPage=_imageTag-1;
//    [self.view addSubview:_pageControl];
//}
//
//-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
//{
//    NSInteger i=scrollView.contentOffset.x/self.view.frame.size.width;
//    _pageControl.currentPage=i;
//    _currentImagePage=i;
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
